﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Announcement.aspx.cs" Inherits="Thksoft.Module.ParameterSettings.Announcement" %>

<!DOCTYPE html>
<html class="L_UI">
<head id="Head1" runat="server">
    <title>公告管理</title>
    <script src="../../Scripts/jquery-1.7.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        var option = {};
        option.Area = ["950px", "460px"];

        option.CancelCallback = function (index, layero) {
            //刷新页面
            $("#btnQuery").click();
        };

        function FORM_INSERT() {

            option.Url = "/Module/ParameterSettings/AnnouncementEdit.aspx";
            option.Title = "新增公告";
            top.MessageBox.Load(option);
        }
        function FORM_EDIT(id) {
            option.Url = "/Module/ParameterSettings/AnnouncementEdit.aspx?ID=" + id;
            option.Title = "编辑公告";
            top.MessageBox.Load(option);
        }

        function btnEdit_Click() {
            var data = GET_CHECKS();
            console.log(data.length);
            if (data.length == 1) {
                if (confirm("是否编辑?")) {
                    FORM_EDIT(data[0].Key);
                }
            }
            else {
                top.MessageBox.Alert("请先选择其中一项");
                return;
            }
        }

        //删除事件
        function btnDelete_Click() {
            var checks = GET_CHECKS();
            if (checks.length == 0) {
                top.MessageBox.Alert("请至少选中一项");
                return;
            }
            if (!confirm('是否删除?')) {
                return;
            }
            else {
                //弹出确定按钮
                var option = {};
                option.Type = "confirm";
                option.Msg = "你确定删除公告（共" + checks.length + "项）？"
                option.YesCallback = function (index) {
                    top.layer.close(index);
                    var str = "";
                    for (var i = 0; i < checks.length; i++) {
                        str += checks[i].Key;
                        if (i + 1 != checks.length) {
                            str += ",";
                        }
                    }
                    $("#DELETE_CHECK_IDS").val(str);
                    $("#ENTRUST_DELETE_BTN").click();

                };
                top.MessageBox.Show(option);
            }
        }

        //发布
        function FORM_FABU(id) {
            //alert("发布公告啦！" + id);
            option.Area = ["950px", "440px"];
            option.Url = "/Module/ParameterSettings/AnnouncementDetail.aspx?ID=" + id;
            option.Title = "发布公告";
            top.MessageBox.Load(option);
        }

        //获取选中的项 （类型对象数组,Item Key 选中项的主键）
        function GET_CHECKS() {
            var data = [];
            $("#grvShow td :checkbox").each(function () {
                if ($(this).is(":checked")) {
                    var key = $(this).attr("data-id");
                    data.push({ Key: key });
                }
            })
            return data;
        }
    </script>
</head>
<body class="bgcss">
    <form id="form1" runat="server">
        <asp:HiddenField runat="server" ID="DELETE_CHECK_IDS" />
        <div class="Window" style="min-width: 1400px;">
            <div class="Header" style="height: 89px;">
                <table border="0" cellpadding="0" cellspacing="0" width="100%" class="table">
                    <tr>
                        <td style="width: 7%; text-align: right; padding-right: 5px;">公司名称：
                        </td>
                        <td align="left" style="padding-left: 10px; width: 20%;">
                            <uc2:CtrlCompany runat="server" ID="FORM_COMPANY_ID" Width="180px" />
                        </td>
                        <td style="width: 7%; text-align: right; padding-right: 5px;">公告标题：
                        </td>
                        <td align="left" style="padding-left: 10px; width: 20%;">
                            <asp:TextBox ID="txtName" CssClass="txt_input" Width="180px" TabIndex="3" runat="server"
                                Height="19px"></asp:TextBox>
                        </td>
                        <td style="width: 7%; text-align: right; padding-right: 5px;">状态：
                        </td>
                        <td align="left" style="padding-left: 10px;">
                            <asp:DropDownList ID="FORM_STATE" CssClass="lblName" runat="server" Width="120px">
                                <asp:ListItem Value="-1">---请选择---</asp:ListItem>
                                <asp:ListItem Value="0">无效</asp:ListItem>
                                <asp:ListItem Value="1">有效</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6" align="center">
                            <asp:Button ID="btnQuery" runat="server" TabIndex="4" Text="查询" CssClass="bt_css_s"
                                OnClick="btnQuery_Click" />&nbsp; &nbsp;
                        <asp:Button ID="btnInsert" runat="server" Text="新增" CssClass="bt_css_s" OnClick="btnInsert_Click" />&nbsp;&nbsp;
                        <button type="button" class="bt_css_s" onclick="btnEdit_Click()">
                            编辑</button>&nbsp;&nbsp;
                        <button type="button" class="bt_css_s" onclick="btnDelete_Click()">
                            删除</button>
                            <asp:Button runat="server" ID="ENTRUST_DELETE_BTN" OnClick="btnDelete_Click" CssClass="hide" />
                        </td>
                    </tr>
                </table>
            </div>
            <div class="Content" style="top: 70px; overflow-y: auto;">
                <div class="Pg-Content">
                    <asp:ScriptManager ID="ScriptManagers" runat="server" EnablePageMethods="True" EnableScriptGlobalization="True"
                        EnableScriptLocalization="True">
                    </asp:ScriptManager>
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                            <asp:GridView ID="grvShow" runat="server" AutoGenerateColumns="False" CssClass="cont_list zebra"
                                Width="100%" EmptyDataText="没有查找到您要的数据" AllowSorting="True" OnSorting="grvShow_Sorting">
                                <Columns>
                                    <asp:TemplateField ItemStyle-Width="20px">
                                        <HeaderTemplate>
                                            <asp:CheckBox ID="chkSelectAll" runat="server" Onclick="GetAllCheckBox(this)" />
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <input type="checkbox" id="chkSelectId" data-id="<%#Eval("N_ID")%>" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField HeaderText="编号" DataField="N_ID" SortExpression="N_ID" ItemStyle-Width="80px" />
                                    <asp:BoundField HeaderText="公司名称" DataField="COMPANYNAME" SortExpression="COMPANYNAME"
                                        ItemStyle-Width="200px" />
                                    <asp:BoundField HeaderText="公告标题" DataField="C_NAME" SortExpression="C_NAME" ItemStyle-Width="200px" />
                                    <asp:BoundField HeaderText="公告内容" DataField="C_CONTENT" SortExpression="C_CONTENT"
                                        ItemStyle-CssClass="left" />
                                    <asp:BoundField HeaderText="发布时间" DataField="D_STARTTIME" SortExpression="D_STARTTIME"
                                        ItemStyle-Width="150px" />
                                    <asp:BoundField HeaderText="到期时间" DataField="D_ENDTIME" SortExpression="D_ENDTIME"
                                        ItemStyle-Width="150px" />
                                    <asp:BoundField HeaderText="发布人" DataField="USERNAME" SortExpression="USERNAME" ItemStyle-Width="120px" />
                                    <asp:BoundField HeaderText="状态" DataField="N_STATE" SortExpression="N_STATE" ItemStyle-Width="100px" />
                                    <asp:BoundField HeaderText="公告类型" DataField="N_TYPE" SortExpression="N_TYPE" ItemStyle-Width="100px" />
                                    <asp:TemplateField HeaderText="发布公告" ItemStyle-Width="80">
                                        <ItemTemplate>
                                            <input type="image" src="/App_Themes/MSN_Blue/Images/message.png" style="width: 20px; height: 20px;" onclick='FORM_FABU(<%#Eval("N_ID") %>);'
                                                title="发布公告" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
                <div class="Pg">
                    <uc1:Pagination ID="PageIng" runat="server" IsDataBindOnLoad="false" OnDataBinding="PageIng_DataBinding"
                        Visible="false" />
                </div>
            </div>
        </div>
    </form>
</body>
</html>